home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 11⁄24⁄89 / 0113-TList problems-Nov89 < prev    next >
Encoding:
Text File  |  1989-11-24  |  2.1 KB  |  62 lines  |  [TEXT/GEOL]

  1. Item forwarded  by  A33          to A34
  2.  
  3. Item    3856820                         22-Nov-89        05:57
  4.  
  5. From:   SW0075                          SWV VTS Transportation Systems, GBG
  6.  
  7. To:     MACAPP.TECH$                    MacApp Technical
  8.  
  9. Sub:    TList problems
  10.  
  11. Hi all,
  12.  
  13. We are having problem using TList for a large number of items.
  14.  
  15. 1 - To insert kNumItems of myItem sequentially in a TList we tested the
  16. following source code:
  17.  
  18.     theListArr:=NewList;
  19.     FOR theIndex:=1 TO kNumItems DO BEGIN
  20.           New(myItem);
  21.           theListArr.InsertLast(myItem);
  22.     END;
  23.  
  24.     This solution is however very slow, probably because InsertLast has to move
  25. the already inserted items as well as add the 4 bytes necessary for the new
  26. item.
  27. Inserting 8000 items (of 30 bytes each) takes 58.4 seconds on my Macintosh
  28. IIcx.
  29.     
  30.     The performance may be improved by first making a Tlist of NIL-items and then
  31. inserting the     real items according to the following source code :
  32.  
  33.     theListArr:=NewList;
  34.     FOR theIndex:=1 TO kNumItems DO BEGIN
  35.           theListArr.InsertLast(NIL);
  36.     END;
  37.  
  38.     FOR theIndex:=1 TO kNumItems DO BEGIN
  39.           New(myItem);
  40.           theListArr.AtPut(theIndex,myItem);
  41.     END;
  42.  
  43.     Now the performance is better, 2.8 seconds for the first loop and 3.3 seconds
  44. for the second. It seems odd that it takes almost as much time to initialize
  45. the TList to the required size     as it takes to create and insert the items. I
  46. suggest that a new method is added to TList to initialize a list of a desired
  47. physical size. If there is a better solution to this problem please inform
  48. about.
  49.     
  50. 2 - While testing the above issues, I notice that the program crashed while
  51. trying to InsertLast item number 8189 (which might be due to some use of
  52. Integers in     the calculation of offsets in TList). This unfortunately restricts
  53. the use of     TList to that number of Items. Is there a way to get round that
  54. restriction? I would be pleased if you removed this restriction, actually I
  55. would be     even more pleased if you redefined the index in TList from Integer to
  56. Longint,     32767 is not a very high value in times of Virtual Memory !
  57.  
  58. Bosse Ridderstolpe
  59. VTS
  60.  
  61.  
  62.